/*==============================================================*/
/* DBMS name:      Microsoft SQL Server 2005                    */
/* Created on:     2009-8-30 16:32:16                           */
/*==============================================================*/


if exists (select 1
            from  sysobjects
           where  id = object_id('rel_user_decorate')
            and   type = 'U')
   drop table rel_user_decorate
go

if exists (select 1
            from  sysobjects
           where  id = object_id('rel_user_friend')
            and   type = 'U')
   drop table rel_user_friend
go

if exists (select 1
            from  sysobjects
           where  id = object_id('rel_user_goods')
            and   type = 'U')
   drop table rel_user_goods
go

if exists (select 1
            from  sysobjects
           where  id = object_id('rel_user_house')
            and   type = 'U')
   drop table rel_user_house
go

if exists (select 1
            from  sysobjects
           where  id = object_id('rel_user_scene')
            and   type = 'U')
   drop table rel_user_scene
go

if exists (select 1
            from  sysobjects
           where  id = object_id('tb_decorate')
            and   type = 'U')
   drop table tb_decorate
go

if exists (select 1
            from  sysobjects
           where  id = object_id('tb_goods')
            and   type = 'U')
   drop table tb_goods
go

if exists (select 1
            from  sysobjects
           where  id = object_id('tb_house')
            and   type = 'U')
   drop table tb_house
go

if exists (select 1
            from  sysobjects
           where  id = object_id('tb_login_history')
            and   type = 'U')
   drop table tb_login_history
go

if exists (select 1
            from  sysobjects
           where  id = object_id('tb_next_id')
            and   type = 'U')
   drop table tb_next_id
go

if exists (select 1
            from  sysobjects
           where  id = object_id('tb_rpc')
            and   type = 'U')
   drop table tb_rpc
go

if exists (select 1
            from  sysobjects
           where  id = object_id('tb_scene')
            and   type = 'U')
   drop table tb_scene
go

if exists (select 1
            from  sysobjects
           where  id = object_id('tb_shop')
            and   type = 'U')
   drop table tb_shop
go

if exists (select 1
            from  sysobjects
           where  id = object_id('tb_user')
            and   type = 'U')
   drop table tb_user
go

if exists (select 1
            from  sysobjects
           where  id = object_id('tb_user_shop_info')
            and   type = 'U')
   drop table tb_user_shop_info
go

if exists (select 1
            from  sysobjects
           where  id = object_id('tc_shop_game_news')
            and   type = 'U')
   drop table tc_shop_game_news
go

if exists (select 1
            from  sysobjects
           where  id = object_id('tc_syslog')
            and   type = 'U')
   drop table tc_syslog
go

/*==============================================================*/
/* Table: rel_user_decorate                                     */
/*==============================================================*/
create table rel_user_decorate (
   user_id              numeric(22)          not null,
   decorate_id          numeric(22)          not null,
   total_amount         numeric(22)          null,
   avalid_amount        numeric(22)          null,
   constraint PK_REL_USER_DECORATE primary key (user_id, decorate_id)
)
go

/*==============================================================*/
/* Table: rel_user_friend                                       */
/*==============================================================*/
create table rel_user_friend (
   user_id              numeric(22)          not null,
   friend_id            numeric(22)          not null,
   constraint PK_REL_USER_FRIEND primary key (user_id, friend_id)
)
go

/*==============================================================*/
/* Table: rel_user_goods                                        */
/*==============================================================*/
create table rel_user_goods (
   user_id              numeric(22)          not null,
   goods_id             numeric(22)          not null,
   amount               numeric(22)          null,
   constraint PK_REL_USER_GOODS primary key (user_id, goods_id)
)
go

/*==============================================================*/
/* Table: rel_user_house                                        */
/*==============================================================*/
create table rel_user_house (
   user_id              numeric(22)          not null,
   house_id             numeric(22)          not null,
   total_amount         numeric(22)          null,
   avalid_amount        numeric(22)          null,
   constraint PK_REL_USER_HOUSE primary key (user_id, house_id)
)
go

/*==============================================================*/
/* Table: rel_user_scene                                        */
/*==============================================================*/
create table rel_user_scene (
   user_id              numeric(22)          not null,
   scene_id             numeric(22)          not null,
   total_amount         numeric(22)          null,
   avalid_amount        numeric(22)          null,
   constraint PK_REL_USER_SCENE primary key (user_id, scene_id)
)
go

/*==============================================================*/
/* Table: tb_decorate                                           */
/*==============================================================*/
create table tb_decorate (
   decorate_id          numeric(22)          not null,
   name                 nvarchar(128)        null,
   description          nvarchar(512)        null,
   price                numeric(18,2)        null,
   src_swf              nvarchar(512)        null,
   shop_class           smallint             null,
   decorate_class       smallint             null,
   constraint PK_TB_DECORATE primary key (decorate_id)
)
go

/*==============================================================*/
/* Table: tb_goods                                              */
/*==============================================================*/
create table tb_goods (
   goods_id             numeric(22)          not null,
   name                 nvarchar(128)        null,
   description          nvarchar(512)        null,
   price                numeric(18,2)        null,
   src_swf              nvarchar(512)        null,
   goods_class          smallint             null,
   sub_class            smallint             null,
   constraint PK_TB_GOODS primary key (goods_id)
)
go

/*==============================================================*/
/* Table: tb_house                                              */
/*==============================================================*/
create table tb_house (
   house_id             numeric(22)          not null,
   name                 nvarchar(128)        null,
   description          nvarchar(512)        null,
   price                numeric(18,2)        null,
   src_swf              nvarchar(512)        null,
   shop_class           smallint             null,
   constraint PK_TB_HOUSE primary key (house_id)
)
go

/*==============================================================*/
/* Table: tb_login_history                                      */
/*==============================================================*/
create table tb_login_history (
   log_id               numeric(22)          not null,
   user_id              numeric(22)          null,
   user_name            nvarchar(128)        null,
   login_time           datetime             null,
   logout_time          datetime             null,
   constraint PK_TB_LOGIN_HISTORY primary key (log_id)
)
go

/*==============================================================*/
/* Table: tb_next_id                                            */
/*==============================================================*/
create table tb_next_id (
   obj_name             varchar(128)         null,
   next_id              numeric(22)          null
)
go

/*==============================================================*/
/* Table: tb_rpc                                                */
/*==============================================================*/
create table tb_rpc (
   rpc_id               numeric(22)          not null,
   name                 nvarchar(128)        null,
   src_swf              nvarchar(512)        null,
   constraint PK_TB_RPC primary key (rpc_id)
)
go

/*==============================================================*/
/* Table: tb_scene                                              */
/*==============================================================*/
create table tb_scene (
   scene_id             numeric(22)          not null,
   name                 nvarchar(128)        null,
   description          nvarchar(512)        null,
   price                numeric(18,2)        null,
   src_swf              nvarchar(512)        null,
   constraint PK_TB_SCENE primary key (scene_id)
)
go

/*==============================================================*/
/* Table: tb_shop                                               */
/*==============================================================*/
create table tb_shop (
   shop_id              numeric(22)          not null,
   name                 nvarchar(128)        null,
   description          nvarchar(512)        null,
   user_id              numeric(22)          null,
   scene_id             numeric(22)          null,
   house_id             numeric(22)          null,
   constraint PK_TB_SHOP primary key (shop_id)
)
go

/*==============================================================*/
/* Table: tb_user                                               */
/*==============================================================*/
create table tb_user (
   user_id              numeric(22)          not null,
   name                 nvarchar(128)        null,
   email                nvarchar(128)        null,
   login_name           nvarchar(128)        null,
   password             nvarchar(128)        null,
   sex                  smallint             null,
   register_time        datetime             null,
   last_login_time      datetime             null,
   is_admin             smallint             null,
   image_src            nvarchar(512)        null,
   constraint PK_TB_USER primary key (user_id)
)
go

/*==============================================================*/
/* Table: tb_user_shop_info                                     */
/*==============================================================*/
create table tb_user_shop_info (
   info_id              numeric(22)          not null,
   user_id              numeric(22)          null,
   score                numeric(18,2)        null,
   game_coin            numeric(18,2)        null,
   deposit              numeric(18,2)        null,
   level                smallint             null,
   constraint PK_TB_USER_SHOP_INFO primary key (info_id)
)
go

/*==============================================================*/
/* Table: tc_shop_game_news                                     */
/*==============================================================*/
create table tc_shop_game_news (
   msg_id               numeric(22)          not null,
   recv_user_id         numeric(22)          null,
   send_user_id         char(10)             null,
   send_time            datetime             null,
   message_text         nvarchar(1024)       null,
   message_type         smallint             null,
   constraint PK_TC_SHOP_GAME_NEWS primary key (msg_id)
)
go

/*==============================================================*/
/* Table: tc_syslog                                             */
/*==============================================================*/
create table tc_syslog (
   log_id               numeric(22)          not null,
   log_time             datetime             null,
   log_text             nvarchar(1024)       null,
   opr_type             smallint             null,
   constraint PK_TC_SYSLOG primary key (log_id)
)
go

